<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>图标配置</title>
    {template 'stourtravel/public/public_min_js'}
    {php echo Common::getCss('base_new.css,base.css,style.css'); }
    {php echo Common::getScript("uploadify/jquery.uploadify.min.js,jquery.validate.js"); }
    {php echo Common::getCss('uploadify.css','js/uploadify/'); }

</head>
<body>

    <div class="pop-info-block">
        <form name="frm" id="frm">
            <ul class="info-item-block">
                <li>
                    <span class="item-hd fl">标题：</span>
                    <div class="item-bd">
                        <input type="text" name="title" id="field_title" class="input-text w100" value="{$info['title']}" />
                    </div>
                </li>
                <li>
                    <span class="item-hd fl">图标：</span>
                    <div class="item-bd">
                        <a class="btn btn-primary radius size-S mt-3" id="upload_btn" href="javascript:;">上传图片</a>
                        <div class="mt-10 mb-10" id="img"><img id="litimg" style="max-width:80px" class="up-img-area" src="{$info['litpic']}" /></div>
                    </div>
                </li>
                <li>
                    <span class="item-hd fl">类型：</span>
                    <div class="item-bd">
                            <label class="radio-label"><input type="radio" name="link_type" {if $info['link_type']==0}checked="checked"{/if} value="0">链接</label>
                            <label class="radio-label ml-20"><input type="radio" name="link_type" {if $info['link_type']==1}checked="checked"{/if} value="1">电话</label>
                        <label class="radio-label ml-20"><input type="radio" name="link_type" {if $info['link_type']==2}checked="checked"{/if} value="2">QQ</label>
                   </div>
                </li>
                <li>
                    <span class="item-hd fl">内容：</span>
                    <div class="item-bd">
                        <input type="text" name="link_content" id="field_link_content"  class="input-text w250" value="{$info['link_content']}" />
                    </div>
                </li>
            </ul>
            <div class="clear clearfix mt-20 text-c">
                <a class="btn btn-primary radius" id="save_btn" href="javascript:;">保存</a>
            </div>
            <input type="hidden" name="litpic" id="field_litpic" value="{$info['litpic']}">
            <input type="hidden" name="id" id="field_id" value="{$info['id']}"/>
        </form>
    </div>

  
  
	<script>
        $(function(){

            $("#frm").validate({
                rules: {
                    title:
                    {
                        required:true
                    },
                    link_content:{
                        required:true
                    }
                },
                messages: {
                    title: {
                        required:"标题不能为空"
                    },
                    link_content:
                    {
                        required:"内容不能为空"
                    }
                },
                submitHandler:function(form){

                    var data={};
                    data.title=$("#field_title").val();
                    data.link_type = $("input[name=link_type]:checked").val();
                    data.link_content=$("#field_link_content").val();
                    data.litpic=$("#field_litpic").val();

                    if(data.litpic=='' || !data.litpic)
                    {
                        ST.Util.showMsg('请选择图标',5,1500);
                        return;
                    }

                    data.id=$("#field_id").val();
                    $.ajax({
                        url:SITEURL+ 'mobile/ajax_footmenu_save',
                        type:'POST',
                        data:data,
                        dataType:'json',
                        success:function(result,textStatus,jqXHR){
                            if(result.status)
                            {
                                ST.Util.responseDialog(result.data,true);
                            }
                            else
                            {
                                ST.Util.showMsg('保存失败',5,1500);
                            }
                        }
                    })

                    return false;
                }

            });





            //上传图片
           //$('#file_upload-button').css('backgroundImage','url("'+PUBLICURL+'images/upload-ico.png'+'")');
            $('#upload_btn').click(function(){
                ST.Util.showBox('上传图片', SITEURL + 'image/insert_view', 0,0, null, null,  parent.document, {loadWindow: window, loadCallback: Insert});
                function Insert(result,bool){
                    if(result.data.length>0){
                        var len=result.data.length-1;
                        var temp =result.data[len].split('$$');
                        $('#litimg')[0].src=temp[0];
                        $("#field_litpic").val(temp[0]);

                    }
                }
            });


            $("#save_btn").click(function(){
                $("#frm").submit();
            });
            //恢复默认
            $("#restore_default").click(function(){
                $("#litpic").val('');
                $("#litimg").attr('src','{$info['default_ico']}');

            });
        })

	</script>
</body>
</html>
